package com.googlecode.flieriya.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.googlecode.flieriya.service.IClusterService;

@Controller
@RequestMapping("/")
public class MainController {
	
	@Autowired
	private IClusterService clusterService;

	@RequestMapping(value="/cluster", method = RequestMethod.GET)
	public String welcome(ModelMap model) {
 
		model.addAttribute("clusterList", clusterService.getAllClusters());
		return "index";
 
	}
 
	@RequestMapping(value="/cluster/{name}", method = RequestMethod.GET)
	public String welcomeName(@PathVariable String name, ModelMap model) {
		clusterService.addCluster(name);
		return "index";
 
	}
}
